<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>注册事件</title>
</head>
<body>
    <button>Change color</button>
    <script>
        var btn = document.querySelector('button');
        function random(number){
            return Math.floor(Math.random()*(number+1))
        }
        btn.ondblclick = function(){
            var rndCol = 'rgb('+random(255)+','+random(255)+','+random(255)+')';
            document.body.style.backgroundColor = rndCol;
        }
    
    </script>
</body>
</html>
